#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
class Solution {
public:
    vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) {
        sort(potions.begin(), potions.end());
        vector<int> ans;
        for (int i = 0; i < spells.size(); ++i) {
            int left = 0, right = potions.size() - 1;
            while (left < right) {
                int mid = left + (right - left) / 2;
                if ((long long)spells[i] * potions[mid] >= success)
                    right = mid;
                else
                    left = mid + 1;
            }
            if ((long long)spells[i] * potions[left] >= success)
                ans.push_back(potions.size() - left);
            else
                ans.push_back(0);
        }
        return ans;
    }
};